Skip to content

Conversation

@mortalYoung
Copy link
Collaborator

变更类型

请选择以下选项以描述 PR 的类型:

  • Bug 修复(修复现有问题)
  • 新功能(添加了一个功能)
  • 代码优化(性能改进、代码重构)
  • 文档更新
  • 单测新增或修改
  • 其他(请说明):

相关问题

变更内容

  • 优化提问为空的 Prompt 渲染
  • 优化 react-markdown 的渲染,避免 validateDOMNesting 问题

详细描述

对应 Previewer

@mortalYoung mortalYoung requested review from LuckyFBB and Copilot June 17, 2025 02:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new feature to support rendering an empty prompt and optimizes the rendering behavior for both typing effects and markdown content, particularly to avoid HTML splitting and validateDOMNesting issues.

  • Introduces a helper function in the typing effect to ensure HTML tags aren’t split.
  • Adds a guard to the prompt component to return null when no title is provided.
  • Modifies the markdown rendering to conditionally use a div element to prevent DOM nesting errors.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/useTyping/index.ts Adds a helper function to calculate the next chunk position without splitting HTML tags.
src/chat/prompt/index.tsx Returns null for empty prompts based on a missing title field.
src/chat/markdown/index.tsx Adjusts paragraph rendering to avoid validateDOMNesting errors with non-text children.
Comments suppressed due to low confidence (2)

src/chat/prompt/index.tsx:31

  • [nitpick] Consider adding a comment here to clarify why the component returns null when 'data.title' is missing, helping maintain readability and understandability of the logic.
if (!data?.title) return null;

src/chat/markdown/index.tsx:51

  • [nitpick] While the conditional rendering prevents validateDOMNesting errors, verify that using a
    instead of a

    for mixed content does not affect the intended semantics or accessibility of the output.

p: (data) => {

@mortalYoung mortalYoung changed the title WIP: feat(chat): support render empty prompt feat(chat): support render empty prompt Jun 17, 2025
@LuckyFBB LuckyFBB requested a review from liuxy0551 June 26, 2025 03:05
@LuckyFBB LuckyFBB merged commit e777034 into DTStack:master Jun 30, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants